import json
import os
import pathlib
from typing import Any, Dict

def extract_filename_without_extension(file_path: str) -> str:
    """
    从文件路径中提取文件名（不含后缀）
    
    参数:
        file_path: 文件路径字符串
        
    返回:
        文件名（不含后缀）
        
    示例:
        extract_filename_without_extension("/home/work/hello.d.ts") -> "hello"
    """
    path = pathlib.Path(file_path)
    directory = str(path.parent)
    filename = path.stem
    return (directory, filename)

def export_to_json(data: Dict[str, Any], file_path: str):
    """将解析结果导出为JSON文件"""
    with open(file_path, 'w', encoding='utf-8') as f:
        json.dump(data, f, indent=2, ensure_ascii=False)
